<!DOCTYPE html>
<html class="x-admin-sm">
  <head>
    <meta charset="UTF-8">
    <title>员工列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="__ADMIN__/css/font.css">
    <link rel="stylesheet" href="__ADMIN__/css/xadmin.css">
    <script type="text/javascript" src="__ADMIN__/js/jquery.min.js"></script>
    <script type="text/javascript" src="__ADMIN__/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__ADMIN__/js/xadmin.js"></script>
    <script type="text/javascript" src="__ADMIN__/js/cookie.js"></script>
    <style>
        .layui-btn+.layui-btn{
            margin-left: 0;
        }
    </style>
  </head>
  
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a><cite>{$nav}</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon layui-icon-refresh-3" style="line-height:30px"></i></a>
    </div>
    <div class="x-body x-admin">
      <xblock>
        {if condition="input('status') neq '0' "}
        <!--<button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>-->
        <button class="layui-btn" onclick="x_admin_show('新增员工','{:url('Staff/add')}')"><i class="layui-icon"></i>新增</button>
       
        <a href="{:url('Staff/lst',['group_id'=>0])}" class="layui-btn layui-btn-primary">全部</a>
        <a href="{:url('Staff/lst',['group_id'=>5])}" class="layui-btn layui-btn-primary">主管</a>
        <a href="{:url('Staff/lst',['group_id'=>2])}" class="layui-btn layui-btn-primary">员工</a>
        <!--<a href="{:url('Staff/lst',['group_id'=>6])}" class="layui-btn layui-btn-primary">回访专员</a>-->
        <a href="{:url('Staff/lst',['group_id'=>7])}" class="layui-btn layui-btn-primary">运营人员</a>
        <a href="{:url('Staff/lst',['group_id'=>8])}" class="layui-btn layui-btn-primary">行政</a>

        {/if}
        <span class="x-right" style="line-height:40px">共有数据：{$count}条</span>

        <div class="layui-card-body" style="padding-left: 0;float:left;padding-left:0px;padding-top:0;">
          <form class="layui-form layui-col-space5" action="?status={:input('status')}" method="get">
              <div class="layui-inline layui-show-xs-block">
                  <input style="width:260px;" type="text" name="keywords" id="search" value="{:input('keywords')}" placeholder="请输入" autocomplete="off" class="layui-input">
              </div>
              <div class="layui-inline layui-show-xs-block">
                  <button class="layui-btn" id="search-btn"><i class="layui-icon"></i></button>
              </div>
          </form>
        </div>
      </xblock>
      <div class="layui-table-body layui-table-main" style="width: 100%;">
      <table class="layui-table layui-form">
        <thead>
          <tr>
            <!--<th style="width: 5%;">-->
            <!--  <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>-->
            <!--</th>-->
            <th>ID</th>
            <th>所属部门</th>
            <th>姓名</th>
            <th>联系方式</th>
            <th>用户名</th>
            <th>角色</th>
            <th>当日录入进度</th>
            <th>入职时间</th>
            <th style="width: 10%;text-align: center;">在职状态</th>
            <th style="text-align: center;">操作</th>
        </thead>
        <tbody>
          {volist name="adminRes" id="admin"}
          <tr>
            <td>{$admin.id}</td>
            <td>{switch $admin.department_id }
    {case 1}可赞{/case}
    {case 2}东创{/case}
    {case 3}雪鲸{/case}
    {case 4}星权{/case}
    {default /} 
{/switch}</td>
            <td>{$admin.name}</td>
            <td>{$admin.phone}</td>
            <td>{$admin.username}</td>
            <td>{$admin.title}</td>
            <td>{$admin.today_count}/{$admin.max_count_day}</td>
            <td>{$admin.join_time|date="Y-m-d",###}</td>
            <td class="td-status" style="width: 10%;text-align: center;">
                <input type="checkbox" name="status" lay-skin="switch" {if condition="$admin['id'] eq 1"}disabled{/if} lay-text="在职|离职" {if condition="$admin['status'] eq 1"}checked{/if} lay-filter="status" id="{$admin.id}" value="{$admin.status}">
            </td>
            <td class="td-manage" style="text-align: center;">
              <a title="业绩" class="layui-btn layui-btn-normal layui-btn-xs" onclick="x_admin_show('{$admin.name} 的业绩','{:url('Staff/yeji',['aid'=>$admin.id])}'),false,'800','600'"  href="javascript:;">
                业绩
              </a>
              <a title="编辑" class="layui-btn layui-btn-normal layui-btn-xs" onclick="x_admin_show('编辑管理员','{:url('Staff/edit',['id'=>$admin.id])}')" href="javascript:;">
                <i class="layui-icon">&#xe642;编辑</i>
              </a>
              <!-- <a title="删除" class='layui-btn layui-btn-xs layui-btn-danger' style="margin: 0px;" onclick="member_del(this,{$admin.id})" href="javascript:;">
                <i class="layui-icon">&#xe640;删除</i>
              </a> -->
            </td>
          </tr>
          {/volist}
        </tbody>
      </table>
    </div>
      <div class="page">
        <div>
          {$adminRes->render()}
        </div>
      </div>
    </div>

    <script>
      layui.use(['form'], function(){
        form = layui.form;
        /*管理员开关*/
        form.on('switch(status)', function(data){
          var obj=data.elem;
          var id = data.elem.id;
          var status = data.value;
          $.ajax({
              type:'POST',
              dataType:'json',
              data:{status:status,id:id},
              url:"{:url('Admin/changeStatus')}",
              success:function(o){
                if(o.icon == 1){
                  $(obj).attr('value',1);
                }else{
                  $(obj).attr('value',0);
                }
                layer.msg(o.msg,{icon: o.icon,time:1000});
              }
            });
        });
      });

      /*管理员-删除*/
      function member_del(obj,id){
          layer.confirm('确认要删除该管理员吗？',function(index){
              //发异步删除数据
              $.ajax({
                type:'POST',
                dataType:'json',
                data:{id:id},
                url:"{:url('Admin/del')}",
                success:function(o){
                  if(o.icon ==1){
                    $(obj).parents("tr").remove();
                  }
                  layer.msg(o.msg,{icon:o.icon,time:1000});
                }
              });
          });
      }
      /*批量删除管理员*/
      function delAll(argument){
        var data = tableCheck.getData();
        if(data == ''){
          layer.msg('请先勾选',{icon:2,time:1000});
          return false;
        }
        layer.confirm('确认要批量删除这些管理员吗？',function(index){
            //发异步删除数据
            $.ajax({
              type:'POST',
              dataType:'json',
              data:{data:data},
              url:"{:url('Admin/delAll')}",
              success:function(o){
                if(o.icon ==1){
                  $(".layui-form-checked").not('.header').not('.id').parents('tr').remove();
                }
                layer.msg(o.msg,{icon:o.icon,time:1000});
              }
            });
        });
      }
    </script>
  </body>

</html>